home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
misc
/
a8085.lha
/
A8085 V1.0
/
SRC
/
Kernal.a
< prev
next >
Wrap
Text File
|
1995-07-31
|
3KB
|
170 lines
; Jumptable
org $FF00
jmp div
jmp mul
jmp print
jmp printbcd
jmp printacc
jmp readstr
jmp readnum
org $F000
; Print the text where (HL) points to until $00
; (HL) points to the byte after $00
print: push psw
jmp begin
loop1: out (0)
begin: mov a,m
inx h
ora a
jnz loop1
pop psw
ret
; Print the BCD number in accumulator
printbcd: push psw
rrc
rrc
rrc
rrc
ani %00001111
jz nonull1
adi 48
out (0)
nonull1: pop psw
push psw
ani %00001111
adi 48
out (0)
pop psw
ret
; Print the number in accumulator
printacc: push psw
push bc
mvi b,100
call div
mov b,a
mov a,c
ora a
jz nonull2
adi 48
out (0)
nonull2: mov a,b
mvi b,10
call div
mov b,a
mov a,c
ora a
jz nonull3
adi 48
out (0)
nonull3: mov a,b
adi 48
out (0)
pop bc
pop psw
ret
; read maximum of accu+1 bytes to where (HL) points to
; (HL) points to the $00 that is appended to the text
; the number of actual bytes read can be found in the accu
readstr: push bc
mov b,a
mov c,a
loop4: in (0)
cpi 8
jnz noback
mov a,b
cmp c
jz loop4 ;not allowed
inr b
dcx h
mvi a,8
out (0)
mvi a,32
out (0)
mvi a,8
out (0)
jmp loop4
noback: cpi 13
jz end
out (0)
mov m,a
inx h
dcr b
jnz loop4
end: mvi m,0
mov a,c
sub b
pop bc
ret
; returns read number in accumulator, flags destroyed
readnum: push de
push bc
mvi d,3
mvi e,0
loop5: in (0)
cpi 8
jnz noback2
mov a,d
cpi 3
jz loop5 ;not allowed
inr d
mvi a,8
out (0)
mvi a,32
out (0)
mvi a,8
out (0)
mov a,e
mvi b,10
call div
mov e,c
jmp loop5
noback2: cpi 13
jz end2
cpi 48
jc loop5 ;char<"0"
cpi 57+1
jnc loop5 ;char>"9"
out (0)
sui 48
mov b,a
mov a,e
mov e,b
mvi b,10
call mul
add e
mov e,a
dcr d
jnz loop5
end2: mvi m,0
mov a,e
pop bc
pop de
ret
; A:=A MOD B, C:=A DIV B, B unchanged and flags as after `CPI 0' command
; WARNING: Does not return for B=0
div: mvi c,$FF
loop2: sub b
inr c
jnc loop2
add b
ret
; A:=A*B, C:=A, B:=0, flags destroyed
mul: mov c,a
mov a,b
ora a
rz
mvi a,0
loop3: add c
dcr b
jnz loop3
ret